package de.tapps.brainstorming;

import java.io.InputStream;
import java.lang.reflect.Method;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Movie;
import android.graphics.Paint;
import android.os.Build;
import android.view.View;
import android.webkit.WebView;

public class MYGIFView extends View {
	Movie movie,movie1;
	InputStream is=null,is1=null;
	long moviestart;
	public MYGIFView(Context context) {
	super(context);
	setBackgroundColor(0x00000000);	

	is=context.getResources().openRawResource(R.drawable.loading);
	movie=Movie.decodeStream(is);

	}

	@Override
	protected void onDraw(Canvas canvas) {
canvas.drawColor(0x00000000);
	super.onDraw(canvas);
	long now=android.os.SystemClock.uptimeMillis();
	System.out.println("now="+now);
	if (moviestart == 0) { // first time
	moviestart = now;

	}
	System.out.println("\tmoviestart="+moviestart);
	int relTime = (int)((now - moviestart) % movie.duration()) ;
	System.out.println("time="+relTime+"\treltime="+movie.duration());
	movie.setTime(relTime);
	movie.draw(canvas,this.getWidth()/2-70,this.getHeight()/2-40);
	this.invalidate();
	}
	
}
